package gui.advancedView;

import gui.mainView.UIView;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import commons.Manager;

import player.Player;
import player.Player.OmxPlayerCommands;


public class UIAdvancedControler implements ActionListener {

	UIView parent;
	UIAdvancedView uiAdvView;

	public UIAdvancedControler(UIAdvancedView uiAdvView, UIView parent){
		this.parent = parent;
		this.uiAdvView = uiAdvView;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		Player.OmxPlayerCommands command = null;
		if(e.getSource().equals(uiAdvView.volMin)){
			command = OmxPlayerCommands.DECREASE_VOLUME;
			}
		else if(e.getSource().equals(uiAdvView.volPlus)){
			command = OmxPlayerCommands.INCREASE_VOLUME;
		}
		else if(e.getSource().equals(uiAdvView.slow)){
			command = OmxPlayerCommands.DECREASE_SPEED;
		}
		else if(e.getSource().equals(uiAdvView.fast)){
			command = OmxPlayerCommands.INCREASE_SPEED;
		}
		else if(e.getSource().equals(uiAdvView.minus600)){
			command = OmxPlayerCommands.SEEK_M600S;
		}
		else if(e.getSource().equals(uiAdvView.minus30)){
			command = OmxPlayerCommands.SEEK_M30S;
		}
		else if(e.getSource().equals(uiAdvView.plus30)){
			command = OmxPlayerCommands.SEEK_P30S;
		}
		else if(e.getSource().equals(uiAdvView.plus600)){
			command = OmxPlayerCommands.SEEK_P600S;
		}
		else if(e.getSource().equals(uiAdvView.previousChapt)){
			command = OmxPlayerCommands.PREVIOUS_CHAPTER;
		}
		else if(e.getSource().equals(uiAdvView.nextChapt)){
			command = OmxPlayerCommands.NEXT_CHAPTER;
		}
		else if(e.getSource().equals(uiAdvView.previousSound)){
			command = OmxPlayerCommands.PREVIOUS_AUDIO_STREAM;
		}
		else if(e.getSource().equals(uiAdvView.nextSound)){
			command = OmxPlayerCommands.NEXT_AUDIO_STREAM;
		}
		else if(e.getSource().equals(uiAdvView.previousSub)){
			command = OmxPlayerCommands.PREVIOUS_SUBTITLE_STREAM;
		}
		else if(e.getSource().equals(uiAdvView.onoff)){
			command = OmxPlayerCommands.TOGGLE_SUBTITLES;
		}
		else if(e.getSource().equals(uiAdvView.nextSub)){
			command = OmxPlayerCommands.NEXT_SUBTITLE_STREAM;
		}
		else if(e.getSource().equals(uiAdvView.close)){
			uiAdvView.kill();
		}
		
		if (command != null) {
			Manager.getInstance().action(command.getCommand());
		}
	}
}